﻿using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using System.Web.UI;
using BLL;
using Model;
using Model.RF.ProductCategory;
using BLL.RF.ProductCategory;

public partial class ProductManage_RFProductManage_View_ProductType_Flow_View : System.Web.UI.Page
{
    public ProductType_Flow pf;
    public string seachFactor
    {
        get { return ViewState["SeachFactor"].ToString(); }
        set { ViewState["SeachFactor"] = value; }
    }

    public ProductManage_RFProductManage_View_ProductType_Flow_View()
    {
        pf = new ProductType_Flow();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            seachFactor = string.Empty;
            BindProductTypeFlow();
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        seachFactor = this.TextBox1.Text.Trim();
        BindProductTypeFlow();
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        seachFactor = string.Empty;
        BindProductTypeFlow();
    }

    public void BindProductTypeFlow()
    {
        if (string.IsNullOrEmpty(seachFactor))
        {
            this.GridView1.DataSource = pf.LoadEntities();
            this.GridView1.DataBind();
        }
        else
        {
            IList<ProductType_FlowInfo> list = new List<ProductType_FlowInfo>();
            list.Add(pf.LoadEntity(seachFactor));
            this.GridView1.DataSource = list;
            this.GridView1.DataBind();
        }        
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        BindProductTypeFlow();
    }
}
